package com.xy.modular.owner.controller;
import com.xy.framework.mreturn.MReturnObject;
import com.xy.modular.owner.model.OwnerDep;
import com.xy.modular.owner.service.IOwnerDepService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 *
 * Created by BCK on 2019/09/14.
 */
@Controller
@RequestMapping("/OwnerDep/")
public class OwnerDepController {

	@Resource
    IOwnerDepService ownerDepService;

    @RequestMapping("add")
    @ResponseBody
    public String add(OwnerDep OwnerDep) {
    	ownerDepService.save(OwnerDep);
        return "";
    }

    @RequestMapping("delete")
    @ResponseBody
    public String delete(@RequestParam String id) {
    	ownerDepService.deleteById(id);
	    return "";
    }

    @RequestMapping("update")
    @ResponseBody
    public String update(OwnerDep OwnerDep) {
    	ownerDepService.update(OwnerDep);
	    return "";
    }

    @RequestMapping("detail")
    @ResponseBody
    public String detail(@RequestParam String id) {
        OwnerDep OwnerDep = ownerDepService.getById(id);
        return OwnerDep.toString();
    }

    @RequestMapping("list")
    @ResponseBody
    public MReturnObject list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
        return new MReturnObject(MReturnObject.SUCCESS, ownerDepService.findAll());
    }
}
